package com.fs.jzzn.pojo;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import com.fs.base.annotation.ColumnDesc;
import com.fs.base.param.SysConstant;
import com.fs.base.pojo.PEntity;
import com.fs.base.utils.ExcelUtils;

/**
 * @Title: jzznpm
 * @Desc: 固定资产实体类
 * @Author: ACE
 * @Date: 2018-11-21-0021 22:35
 * @Version: 1.0
 */
@Entity
@Table(name="p_fixed_assets")
@NoArgsConstructor
@AllArgsConstructor
@Data
@EqualsAndHashCode(callSuper=false)
public class FixedAssets  extends PEntity{
    //数据导入对应关系
    public static final Map<String,String> map = new HashMap<>();

    static{
    	map.put("资产编号","no");
        map.put("资产类别","type");
        map.put("年份","year");
        map.put("资产名称","name");
        map.put("购进日期","purchaseDate");
        map.put("规格型号","specifications");
        map.put("计量单位","metering");
        map.put("数量","count");
        map.put("原值(金额)","money");
        map.put("估计现值","present");
        map.put("使用部门","orgNoName");
        map.put("使用人","people");
        map.put("资产状态","assets");
        map.put("创建时间","createTime");
        map.put("创建人","createrId");
    }

    @ColumnDesc(name="资产类别")
    @Column(name="type", columnDefinition = "varchar(100) COMMENT '资产类别'")
    public String type;

    @ColumnDesc(name="年份")
    @Column(name="year", columnDefinition = "varchar(10) COMMENT '年份'")
    public String year;

    @ColumnDesc(name="资产编号")
    @Column(name="no", columnDefinition = "varchar(20) COMMENT '资产编号'")
    public String no;

    @ColumnDesc(name="资产名称")
    @Column(name="name", columnDefinition = "varchar(100) COMMENT '资产名称'")
    public String name;

    @ColumnDesc(name="购进日期")
    @Column(name="purchase_date", columnDefinition = "varchar(10) COMMENT '购进日期'")
    public String purchaseDate;

    @ColumnDesc(name="规格型号")
    @Column(name="specifications", columnDefinition = "varchar(50) COMMENT '规格型号'")
    public String specifications;

    @ColumnDesc(name="计量单位")
    @Column(name="metering", columnDefinition = "varchar(10) COMMENT '计量单位'")
    public String metering;

    @ColumnDesc(name="数量")
    @Column(name="count", columnDefinition = "varchar(5) COMMENT '数量'")
    public String count;

    @ColumnDesc(name="原值(金额)")
    @Column(name="money", columnDefinition = "varchar(20) COMMENT '原值(金额)'")
    public String money;

    @ColumnDesc(name="估计现值")
    @Column(name="present", columnDefinition = "varchar(20) COMMENT '估计现值'")
    public String present;

    @ColumnDesc(name="使用人")
    @Column(name="people", columnDefinition = "varchar(20) COMMENT '使用人'")
    public String people;

    @ColumnDesc(name="单价")
    @Column(name="price", columnDefinition = "varchar(20) COMMENT '单价'")
    public String price;

    @ColumnDesc(name="资产状态")
    @Column(name="assets", columnDefinition = "varchar(100) COMMENT '资产状态'")
    public String assets;
    
    
    public static List<FixedAssets> excelDataFormat(List<List<String>> data){
		List<FixedAssets> list = new ArrayList<FixedAssets>();
		for(List<String> rowData: data){
			list.add(excelData2Bean(rowData));
		}
		return list;
	}
    
    private static FixedAssets excelData2Bean(List<String> row){
		row = ExcelUtils.dataLenFomart(row, 15);
		FixedAssets f = new FixedAssets();
		f.setNo(row.get(0));
		f.setType(row.get(1));
		f.setYear(row.get(2));
		f.setName(row.get(3));
		f.setPurchaseDate(row.get(4));
		f.setSpecifications(row.get(5));
		f.setMetering(row.get(6));
		f.setCount(row.get(7));
		f.setMoney(row.get(8));
		f.setPresent(row.get(9));
		f.setOrgNo(SysConstant.getKey(SysConstant.ORG_NO_NAME_MAP, row.get(10)));
		f.setPeople(row.get(11));
		f.setAssets(row.get(12));
		f.setCreateTime(new Date());
		f.setCreaterId(SysConstant.getKey(SysConstant.USERS_ID_NAME_MAP,row.get(14)));
		return f;
	}

}
